/**
 * 268. 丢失的数字
 * 1、位图；2高斯求和；3、异或
 */
class Solution6 {
    public int missingNumber(int[] nums) {
        int n = nums.length;
        int[] hash = new int[n + 1];
        hash[n] = -1;
        for(int i = 0; i < n; i++) {
            hash[nums[i]] = 1;
        }
        for(int i = 0; i < n + 1; i++) {
            if(hash[i] == 0) return i;
        }

        return -1;
    }
}